$(() => {
  let optionOnly = {
    legend: {
      data: ['故障', '正常','维修'],
      x: '95px',
      y: '240px',
      selected: false
    },
    color: ['#0886e2','#f8b811','rgb(252,61,83)' ],
    series: [
      {
        type: 'pie',
        radius: '55%',
        center: ['50%', '45%'],
        data: [
          {value: 70, name: '正常'},
          {value: 20, name: '维修'},
          {value: 10, name: '故障'}
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  };
  let panel = echarts.init(document.getElementById('faultRateBar_cc'));
  panel.setOption(optionOnly);

  let showtime = function (date) {
    let nowTime = new Date(),  //获取当前时间
      endTime = new Date(date);  //定义结束时间
    let leftTime = endTime.getTime() - nowTime.getTime(),  //距离结束时间的毫秒数
      leftH = Math.floor(leftTime / (1000 * 60 * 60)) < 10 ? '0' + Math.floor(leftTime / (1000 * 60 * 60)) : Math.floor(leftTime / (1000 * 60 * 60)),  //计算小时数
      leftM = Math.floor(leftTime / (1000 * 60) % 60) < 10 ? '0' + Math.floor(leftTime / (1000 * 60) % 60) : Math.floor(leftTime / (1000 * 60) % 60),  //计算分钟数
      leftS = Math.floor(leftTime / 1000 % 60) < 10 ? '0' + Math.floor(leftTime / 1000 % 60) : Math.floor(leftTime / 1000 % 60);  //计算秒数
    return {h: leftH, m: leftM, s: leftS};  //返回倒计时的字符串
  };

  setInterval(function () {
    $('.weatherTime > div:nth-child(1)>p:nth-child(1)').text(getTime());
    $('.weatherTime > div:nth-child(1)>p:nth-child(2)').text(getDate());

    $('.nextTime>p:nth-child(2)>span:nth-child(1)').text(showtime('2021/9/1').h);
    $('.nextTime>p:nth-child(2)>span:nth-child(3)').text(showtime('2021/9/1').m);
    $('.nextTime>p:nth-child(2)>span:nth-child(5)').text(showtime('2021/9/1').s);
  }, 1000);
  getWeather("长春", 'weather_cc', 'pic_cc', 1);
});